D:\git\skunkworks\herald-for-cpp\herald\src\datatype\target_identifier.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2020-2021 Herald Project Contributors |
2 | | // SPDX-License-Identifier: Apache-2.0 |
3 | | // |
4 | | |
5 | | #include "herald/datatype/target_identifier.h" |
6 | | #include "herald/datatype/data.h" |
7 | | |
8 | | namespace herald { |
9 | | namespace datatype { |
10 | | |
11 | | // class TargetIdentifier::Impl { |
12 | | // public: |
13 | | // Impl(); |
14 | | // Impl(const Data& mac); |
15 | | // Impl(const TargetIdentifier& from); |
16 | | // ~Impl() = default; |
17 | | |
18 | | // Data value; |
19 | | // }; |
20 | | |
21 | | // TargetIdentifier::Impl::Impl() |
22 | | // : value() |
23 | | // { |
24 | | // ; |
25 | | // } |
26 | | |
27 | | // TargetIdentifier::Impl::Impl(const Data& v) |
28 | | // : value(v) |
29 | | // { |
30 | | // ; |
31 | | // } |
32 | | |
33 | | // TargetIdentifier::Impl::Impl(const TargetIdentifier& v) |
34 | | // : value((Data)v) // conversion operator |
35 | | // { |
36 | | // ; |
37 | | // } |
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
45 | | TargetIdentifier::TargetIdentifier() |
46 | | : value() |
47 | 111 | { |
48 | 111 | ; // TODO set value to random v4 UUID string |
49 | 111 | } |
50 | | |
51 | | TargetIdentifier::TargetIdentifier(const Data& data) |
52 | | : value(data) |
53 | 44 | { |
54 | 44 | ; |
55 | 44 | } |
56 | | |
57 | | TargetIdentifier::TargetIdentifier(const TargetIdentifier& from) |
58 | | : value(from.value) |
59 | 88 | { |
60 | 88 | ; |
61 | 88 | } |
62 | | |
63 | 243 | TargetIdentifier::~TargetIdentifier() {} |
64 | | |
65 | | TargetIdentifier& |
66 | | TargetIdentifier::operator=(const TargetIdentifier& from) |
67 | 17 | { |
68 | 17 | value = from.value; |
69 | 17 | return *this; |
70 | 17 | } |
71 | | |
72 | | bool |
73 | 59 | TargetIdentifier::operator==(const TargetIdentifier& other) const noexcept { |
74 | 59 | return hashCode() == other.hashCode(); |
75 | 59 | } |
76 | | |
77 | | bool |
78 | 1 | TargetIdentifier::operator==(const Data& other) const noexcept { |
79 | 1 | return value == other; |
80 | 1 | } |
81 | | |
82 | | bool |
83 | 18 | TargetIdentifier::operator!=(const TargetIdentifier& other) const noexcept { |
84 | 18 | return hashCode() != other.hashCode(); |
85 | 18 | } |
86 | | |
87 | | bool |
88 | 1 | TargetIdentifier::operator!=(const Data& other) const noexcept { |
89 | 1 | return value != other; |
90 | 1 | } |
91 | | bool |
92 | 0 | TargetIdentifier::operator<(const TargetIdentifier& other) const noexcept { |
93 | 0 | return value < other.value; |
94 | 0 | } |
95 | | |
96 | | bool |
97 | 0 | TargetIdentifier::operator>(const TargetIdentifier& other) const noexcept { |
98 | 0 | return value > other.value; |
99 | 0 | } |
100 | | |
101 | | std::size_t |
102 | 158 | TargetIdentifier::hashCode() const { |
103 | 158 | return std::hash<Data>{}(value); |
104 | 158 | } |
105 | | |
106 | 44 | TargetIdentifier::operator std::string() const { |
107 | 44 | return value.description(); |
108 | 44 | } |
109 | | |
110 | 8 | TargetIdentifier::operator Data() const { |
111 | 8 | return value; |
112 | 8 | } |
113 | | |
114 | | Data |
115 | 21 | TargetIdentifier::underlyingData() const { |
116 | 21 | return Data(value); |
117 | 21 | } |
118 | | |
119 | | } // end namespace |
120 | | } // end namespace |